﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.BLL;
using COM.OA.Entity;
using System.Collections.Generic;

public partial class deletegroups : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //接收要删除的群ID
        string qunid = this.Request["deletequnid"];
        //判断群ID是否为空
        if (qunid != null)
        {
            //格式化成INT类型
            int id = Int32.Parse(qunid);
            string where = "u_g_id='{0}'";
            where = string.Format(where, id);
            //先查出群里所有人员
            IList<users> ulist = usersBLL.Select(where);
            //循环用实体接收，将其群组更改为NULL
            foreach (users uu in ulist)
            {
                uu.u_g_id = 1;
                usersBLL.Update(uu);
            }
            //删除群组
            groupsBLL.Delete(id);
            this.Response.Write(string.Format(GetRedirect.WINALERT, "删除成功"));
        }
            //如果群ID为空跳回qunzu.aspx页
        else
        {
            this.Response.Write(string.Format(GetRedirect.REDIRECT, "qunzu.aspx"));
        }
    }
}
